import os, sys, stat

# 权限：文件是否存在
# ret = os.access("data.pkl", os.F_OK)
# print("F_OK - 返回值 %s" % ret)
# # 返回当前工作目录
# print('当前工作目录 :%s' % os.getcwd())
# # 返回相关文件的系统配置信息。
# fd = os.open( "data.pkl", os.O_RDWR|os.O_CREAT )
# #os.pathconf(fd, 'PC_LINK_MAX')
# #删除
# b_p=os.access('E:\\Xm\\Test\\t_d\\tt',os.W_OK)
# print('修改前权限：%s'%b_p)
# chper=os.chmod('E:\\Xm\\Test\\t_d\\tt', stat.S_IRWXO)
# a_p=os.access('E:\\Xm\\Test\\t_d\\tt',os.W_OK)
# print('修改后权限：%s'%a_p)
# print('chper-:%s'%chper)
# r = os.remove('E:\\Xm\\Test\\t_d\\tt')
# print('s删除结果：%s'%r)
# 异常
# try:
#     f = open('myfile.txt')
#     s = f.readline()
#     i = int(s.strip())
# except OSError as err:
#     print("OS error: {0}".format(err))
# except ValueError:
#     print("Could not convert data to an integer.")
# except:
#     print("Unexpected error:", sys.exc_info()[0])
#     raise
# 自定义异常

class MyError(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)

try:
    raise MyError(2 * 2)
except MyError as e:
    print('My exception occurred, value:', e.value)
# 定义函数
def temp_convert(var):
    try:
        return int(var)
    except ValueError as Argument:
        print ("参数没有包含数字\n", Argument)

# 调用函数
temp_convert("xyz");

import math
print(math.pi)
print(math.sin(0.5))